﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ArithmeticLibrary.Tree
{
    /// <summary>
    /// Trida reprezentujici listy s cislama.
    /// </summary>
    public class NumberNode : LeafNode
    {
        #region Fields

        /// <summary>
        /// Hodnota cisla.
        /// </summary>
        private readonly double value;

        #endregion

        #region Properties

        /// <summary>
        /// Vrati hodnotu cisla.
        /// </summary>
        public double Value { get { return value; } }

        #endregion // Properties

        #region Constructors

        /// <summary>
        /// Vytvori instanci NumberNode.
        /// </summary>
        /// <param name="number"></param>
        public NumberNode(double number)
        {
            this.value = number;
        }

        #endregion // Constructors

        public override double Evaluate(double x)
        {
            return value;
        }

        public override R Accept<R, C>(IExpressionVisitor<R, C> visitor, C context)
        {
            return visitor.Visit(this, context);
        }
    }
}
